<{include file="header.html"}>

<script type="text/javascript">
function checkValidForm()
{
    var email = document.getElementById("EMAIL");
    var id = document.getElementById("annonceur_id");
    var pass = document.getElementById("PASS");
    var pass_confirm = document.getElementById("PASS_CONFIRM");
    var nom = document.getElementById("NOM");
    var prenom = document.getElementById("PRENOM");
    var fax = document.getElementById("FAX");
    var code = document.getElementById("CODE");
    var fonction = document.getElementById("FONCTION");

    if(email.value == "")
    {
        showErrorBubble(email, "<{$smarty.const._LB_EMAIL_IS_EMPTY|utf8_escape_js}>");
        return false;
    }
    else if(!isValidEmail(email, "<{$smarty.const._LB_INVALID_EMAIL|utf8_escape_js}>"))
    {
        return false;
    }
    if(!isValidLengthTextBox(email, <{$smarty.const.MAX_LENGTH_NAME}>, "<{$smarty.const._MSG_EMAIL_IS_TOO_LONG|utf8_escape_js}>"))
    {
        return false;
    }

    <{if $annonceur->ID==0}>

        if(!isValidLengthTextBox(pass, <{$smarty.const.MAX_LENGTH_PASSWORD}>, "<{$smarty.const._MSG_PASSWORD_IS_TOO_LONG|utf8_escape_js}>"))
        {
            return false;
        }
        if(!isValidMinLengthTextBox(pass, <{$smarty.const.MIN_LENGTH_PASSWORD}>, "<{$smarty.const._MSG_PASSWORD_IS_TOO_SHORT|utf8_escape_js}>"))
        {
            return false;
        }
        if (pass.value != pass_confirm.value)
        {
            showErrorBubble(pass, "<{$smarty.const._LB_PASSWORD_DOESNT_MATCH|utf8_escape_js}>" );
            return false;
        }

        if ((pass.value == "") || (pass_confirm.value == ""))
        {
            showErrorBubble(pass, "<{$smarty.const._LB_INVALID_PASSWORD|utf8_escape_js}>" );
            return false;
        }

    <{/if}>

    if(isEmptyTextBox(nom, '<{$smarty.const._LB_NAME_IS_EMPTY|utf8_escape_js}>'))
    {
        return false;
    }
    if(!isValidLengthTextBox(nom, <{$smarty.const.MAX_LENGTH_NAME}>, "<{$smarty.const._LB_INVALID_LENGTH_NOM|utf8_escape_js}>"))
    {
        return false;
    }
    if(!isValidLengthTextBox(prenom, <{$smarty.const.MAX_LENGTH_NAME}>, "<{$smarty.const._LB_PRENOM_IS_TOO_LONG|utf8_escape_js}>"))
    {
        return false;
    }
    if(code.value == ""){
        showErrorBubble(code, "<{$smarty.const._MSG_CODE_IS_EMPTY|utf8_escape_js}>");
        return false;
    }
    else if(code.value.length != <{$smarty.const.MAX_LENGTH_USER_CODE}>)
    {
        showErrorBubble(code, "<{$smarty.const._MSG_CODE_IS_INVALID|utf8_escape_js}>");
        return false;
    }
    else
    {
        var code_value = code.value;
        var code_pattern = /[a-z0-9A-Z]{3}/;

        if (!code_pattern.test(code_value))
        {
            showErrorBubble(code, "<{$smarty.const._MSG_CODE_IS_INVALID|utf8_escape_js}>");
            return false;
        }
    }

    if(!isValidLengthTextBox(fax, <{$smarty.const.MAX_LENGTH_NAME}>, "<{$smarty.const._MSG_FAX_IS_TOO_LONG|utf8_escape_js}>"))
    {
        return false;
    }
    if(!isValidLengthTextBox(fonction, <{$smarty.const.MAX_LENGTH_NAME}>, "<{$smarty.const._LB_FONCTION_IS_TOO_LONG|utf8_escape_js}>"))
    {
        return false;
    }

    // check whether or not email exist
    var agr = new Array();
    agr.push(email.value);
    agr.push('<{$annonceur->ID}>');

    if(callFunction("Login::emailExistByLoginID", agr))
    {
        showErrorBubble(email, "<{$smarty.const._LB_INVALID_EMAIL|utf8_escape_js}>" );
        return false;
    }

    // check whether or not CODE exist, CODE must be unique
    agrs = new Array();
    agrs.push(code.value);
            agrs.push('<{$annonceur->ID}>');
    if (callFunction("Login::codeExistByLoginID", agrs))
    {
        showErrorBubble(code, "<{$smarty.const._MSG_CODE_EXISTS|utf8_escape_js}>" );
        return false;
    }

    document.annonceur_edit.submit();
}

</script>
	<div id="form_add" class="one_center">
		<div class="box_two_third">
			<div class="box_head"><{$lb_head_box}></div>

			<div class="box_content">
				<div class="message">
					<{include file="message.html"}>
				</div>

				<form action="#" method="post" name="annonceur_edit">
					<table class="formInput">
					<tbody>
					<{if $account_type == $smarty.const.ACCOUNT_TYPE_SUPPORT }>
					 <tr>
						<td><{$smarty.const._LB_EMAIL|utf8_escape_html}>	<font color="#ff0000">*</font> :
						</td>
						<td>
							<input type="text" maxlength="100" size="30" value="<{$annonceur->EMAIL|utf8_escape_html}>" id="EMAIL" name="EMAIL"/>
						</td>
					 </tr>
					 <{if $annonceur->ID==0}>
						<tr>
							<td>
								<{$smarty.const._LB_PASSWORD|utf8_escape_html}>&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}> :
							</td>
							<td>
								<input id="PASS" type="password" maxlength="255" size="30" value="" name="PASS"/>
							</td>
						</tr>

						<tr>
							<td>
								<{$smarty.const._LB_REPEAT_PASSWORD|utf8_escape_html}>&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}> :
							</td>
							<td>
								<input id="PASS_CONFIRM" type="password" maxlength="255" size="30" value="" name="PASS_CONFIRM"/>
							</td>
						</tr>
						<{/if}>
					 <tr>
						<td><{$smarty.const._LB_NOM|utf8_escape_html}>&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}> :
						</td>
						<td>
							<input type="text" maxlength="100" size="30" value="<{$annonceur->NOM|utf8_escape_html}>" id="NOM" name="NOM"/>
						</td>
					 </tr>

					 <tr>
						<td><{$smarty.const._LB_PRENOM|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" maxlength="100" size="30" value="<{$annonceur->PRENOM|utf8_escape_html}>" id="PRENOM" name="PRENOM"/>
						</td>
					 </tr>

					 <tr>
						<td><{$smarty.const._LB_CODE|utf8_escape_html}>&nbsp;<{$smarty.const._LB_REQUIRE_FIELD}> :
						</td>
						<td>
							<input type="text" maxlength="3" size="4" value="<{$annonceur->CODE}>" id="CODE" name="CODE"/>
						</td>
					 </tr>

					 <tr>
						<td><{$smarty.const._LB_FAX|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" maxlength="20" size="30" value="<{$annonceur->FAX}>" id="FAX" name="FAX"/>
						</td>
					 </tr>

					 <tr>
						<td><{$smarty.const._LB_FONCTION|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" maxlength="255" size="30" value="<{$annonceur->FONCTION|utf8_escape_html}>" id="FONCTION" name="FONCTION"/>
						</td>
					 </tr>
					<{else}>
					 <tr>
						<td><{$smarty.const._LB_NOM|utf8_escape_html}>
							<font color="#ff0000">*</font>
							:
						</td>
						<td>
							<input type="text" size="30" value="<{$annonceur->NOM|utf8_escape_html}>" id="NOM" name="NOM"/>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_TELEPHONE|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" size="30" value="<{$annonceur->TELEPHONE|utf8_escape_html}>" id="TELEPHONE" name="TELEPHONE" />
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_FAX|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" size="30" value="<{$annonceur->FAX}>" id="FAX" name="FAX"/>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_SIRET|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" size="30" maxlength="50" value="<{$annonceur->SIRET}>" id="SIRET" name="SIRET"/>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_ADRESSE|utf8_escape_html}> :
						</td>
						<td>
							<textarea cols="30" class="user_form_textarea" id="ADDRESS" name="ADDRESS"><{$annonceur->ADDRESS|utf8_escape_textarea}></textarea>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_BILLING_ADRESSE|utf8_escape_html}> :
						</td>
						<td>
							<textarea cols="30" class="user_form_textarea" id="BILL_ADDRESS" name="BILL_ADDRESS"><{$annonceur->BILL_ADDRESS|utf8_escape_textarea}></textarea>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_INVOICING_CODE|utf8_escape_html}> :
						</td>
						<td>
							<input type="text" size="30" maxlength="50" value="<{$annonceur->INVOICING_CODE}>" id="INVOICING_CODE" name="INVOICING_CODE"/>
						</td>
					 </tr>
					 <tr>
						<td><{$smarty.const._LB_FOREIGNER_INDICATOR|utf8_escape_html}> :
						</td>
						<td align="left" style="padding-left:0px;">
							<input name="FOREIGNER_INDICATOR" id="FOREIGNER_INDICATOR" type="checkbox" <{if $annonceur->FOREIGNER_INDICATOR}> checked="checked" <{/if}> value="1"/>
						</td>
					 </tr>
					 <{/if}>
					 <tr>
						<td class="submit" colspan="2" style="padding-top: 5px;">
							<a class="tribullet" id="btnReturn" href="<{$backlink}>"><{$smarty.const._LB_BACK}></a>
							&nbsp;&nbsp;
							<a class="tribullet" href="#" onclick="checkValidForm();"><{$smarty.const._LB_VALIDATE}></a>
						</td>
					 </tr>
					</tbody>
				</table>

				<input type="hidden" value="<{$annonceur->ID}>" name="annonceur_id" id="annonceur_id" />
				<input type="hidden" value="<{$account_type}>" name="account_type"/>
				<input type="hidden" value="<{$smarty.const.ACT_VALID_EDIT}>" name="act"/>
			</form>
		</div>
	</div>
</div>
<{include file="footer.html"}>
